<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>凡客诚品 - 会员登录</title>
	<link rel="stylesheet" href="__STATIC__/Index/css/login.css" />
	<script type="text/javascript" src="__STATIC__/Index/js/jquery-1.7.2.min.js"></script>
	<script>	
		function change_code(){
			var img = document.getElementById('img_code');
			var src = img.getAttribute('src');
			var pos = src.lastIndexOf('&t=');
			if (pos > 0){
				src = src.substr(0, pos);
			}
			src += ('&t=' + Math.random());
			img.setAttribute('src', src);
		}	
		
		var validate = {
			username: false,
			password: false,
		};		
		
		$(function(){
			$('input[name=username]').blur(function(){
				var username = $('input[name=username]').val().trim();
				if (username != ''){
					$('#userNameError').removeClass('show');
					$("#userNameError").html('');
					validate.username = true;
				}else{
					validate.username = false;
				}
			});
			
			$('input[name=password]').blur(function(){
				var password = $('input[name=password]').val().trim();
				if (password != ''){
					$('#userPasswordError').removeClass('show');
					$("#userPasswordError").html('');
					validate.password = true;
				}else{
					validate.password = false;
				}
			});			
			
			$('#a_login').click(function(){	
				$('#userNameError').removeClass('show');
				$('#userPasswordError').removeClass('show');
				$('#userCodeError').removeClass('show');
				
				if (!validate.username){
					$('#userNameError').addClass('show');
					$("#userNameError").html('用户名不能为空');
					return false;
				}
				
				if (!validate.password){
					$('#userPasswordError').addClass('show');
					$("#userPasswordError").html('密码不能为空');
					return false;
				}
				
				var code = $('input[name=code]').val().trim();
				if (code == ''){
					$('#userCodeError').addClass('show');
					$('#userCodeError').html('请输入验证码');
					return false;
				}
				
				var formData = $('form').serialize();
				$.ajax({
					type: 'post',
					url: "{|U:'Member/ajaxLogin'}",
					data: formData,
					dataType: 'json',
					success:function(phpData){
						switch (phpData.errno){
							case 1:
								// 验证码正确
								$('#userCodeError').addClass('show');
								$('#userCodeError').html(phpData.error);
								break;
							case 2:
								// 用户不存在
								$('#userNameError').addClass('show');
								$('#userNameError').html(phpData.error);
								break;
							case 3:
								// 用户名和密码不匹配
								$('#userPasswordError').addClass('show');
								$('#userPasswordError').html(phpData.error);
							case 0:
								// 登录成功
								location.href = "{|U:'Index/Index'}";
						}
					}
				})
				
				return false;
			})
		})
	</script>
</head>
<body>
	<div class="headWrap">
		<div id="Head">
			<a class="logo" href="{|U:'Index/Index'}">	</a>
			<p><a href="" class="a_black">帮助</a></p>
		</div>
	</div>
	<div class="contentWrap">
		<div class="login">
			<div class="tag">
				<ul id="tags">
					<li class="on">VANCL用户</li>
					<li></li>
				</ul>
			</div>
			<div class="user_info">
				<form action="javascript:;" method="post">
					<div id="logError" class="tips"></div>
					<p>
						<label for="">用户名:</label>
						<input type="text" placeholder="" name="username" />
					</p>
					<div id="userNameError" class="tips"></div>
					<p>
						<label for="">密&nbsp;&nbsp;码:</label>
						<input type="password" name="password" id="" />
					</p>
					<div id="userPasswordError" class="tips">密码不匹配</div>
					<div class="div_code">
						<div class="code_label fl">
							<label for="">验证码:</label>
							<input type="text" name="code" id="code" />
						</div>
						<div class="code_code fl">
							<img id="img_code" src="{|U:'Member/Code'}" alt="" onclick="change_code();"/>
						</div>
						<div class="code_refresh fl">
							<a class="a_changeCode" href="javascript:;" onclick="change_code()">刷新</a>
						</div>
						<div class="clearfix"></div>	
					</div>
					<div id="userCodeError" class="tips"></div>
	
					<div class="bt">
						<a id="a_login" href="javascript:;" class="log"/>登&nbsp;&nbsp;录</a>
						<a class="reg a_black" href="{|U:'Member/Reg'}">立即注册</a>
					</div>
				</form>
			</div>
		</div>
		<div class="ad">
			<img src="__STATIC__/Index/images/ad_login.jpg" alt="" />
		</div>
		<div style="clear:both"></div>		
	</div>
	<div class="bottom">
		<p>Copyright 2007 - 2014 vancl.com All Rights Reserved 京ICP证100557号 京公网安备11010102000579号 出版物经营许可证新出发京批字第直110138号</p>
	</div>
	
</body>
</html>